#pragma once
#include<functional>
#include<iostream>
#include<vector>
#include<ctime>
#include<cstdlib>
using work_t=std::function<void()>;

void download()
{
    std::cout<<"我是下载任务"<<std::endl;
}
void log()
{
    std::cout<<"我是日志任务"<<std::endl;
}
void SQL()
{
    std::cout<<"我是数据库任务"<<std::endl;
}


class task
{
public:
    task()
    {
        srand(time(nullptr));
        tasks.push_back(download);
        tasks.push_back(log);
        tasks.push_back(SQL);
    }
    int select()
    {
        return rand()%tasks.size();
    }
    void excute(int id)
    {
        if(id>=(int)tasks.size()||id<0)
            return;
        tasks[id]();
    }
    ~task()
    {

    }
private:
    std::vector<work_t> tasks;
};

task ts;



